package com.cats.template.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cats.template.sys.pojo.model.PermissionModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * @author duxiaobo
 * @date 2021/9/102:35 下午
 */
@Mapper
public interface PermissionMapper extends BaseMapper<PermissionModel> {

    @Select("SELECT * from sys_permissions where id in (" +
            "SELECT permission_id from sys_roles_permissions where role_id = #{roleId} and delete_flg = 0" +
            ") and delete_flg = 0")
    Set<PermissionModel> getPermissionsByRoleId(@Param("roleId") Long roleId);

    @Select("SELECT * from sys_permissions where delete_flg = 0 order by order_number asc")
    Set<PermissionModel> getAll();
}
